From 47a078f10128e9b8334a054ec70419c10a11415b Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Fri, 28 Jul 2006 17:00:10 +0100 Subject: [PATCH] [NET] front: Clean up rx ring recovery. Signed-off-by: Keir Fraser This is an update to c/s 10855:03c8002068d9d60c7bbfc2f41af975e09b2e2211 which should have contained the following changeset message (rather than 'Merge.'). [NET] front: Stop using rx->id With the current protocol for transferring packets from dom0 to domU, the rx->id field is useless because it can be derived from the rx request ring ID. In particular, rx->id = (ring_id & NET_RX_RING_SIZE - 1) + 1; This formula works because the rx response to each request always occupies the same slot that the request arrived in. This in turn is a consequence of the fact that each packet only occupies one slot. The other important reason that this works for dom0=>domU but not domU=>dom0 is that the resource associated with the rx->id is freed immediately while in the domU=>dom0 case the resource is held until the skb is liberated by dom0. Using this formula we can essentially remove rx->id from the protocol, freeing up space that could be instead be used by things like TSO. The only constraint is that the backend must obey the rule that each id must only be used in the response that occupies the same slot as the request. The actual field of rx->id is still maintained for compatibility with older backends. Signed-off-by: Herbert Xu --- .../drivers/xen/netfront/netfront.c | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c index 1db6bbc9d7..41fddd04b0 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -1193,19 +1193,16 @@ static void network_connect(struct net_device *dev) if (!np->rx_skbs[i]) continue; + skb = np->rx_skbs[requeue_idx] = xennet_get_rx_skb(np, i); + ref = np->grant_rx_ref[requeue_idx] = xennet_get_rx_ref(np, i); + gnttab_grant_foreign_transfer_ref( - np->grant_rx_ref[i], np->xbdev->otherend_id, - __pa(np->rx_skbs[i]->data) >> PAGE_SHIFT); - RING_GET_REQUEST(&np->rx, requeue_idx)->gref = - np->grant_rx_ref[i]; - RING_GET_REQUEST(&np->rx, requeue_idx)->id = requeue_idx; - - if (requeue_idx < i) { - np->rx_skbs[requeue_idx] = np->rx_skbs[i]; - np->grant_rx_ref[requeue_idx] = np->grant_rx_ref[i]; - np->rx_skbs[i] = NULL; - np->grant_rx_ref[i] = GRANT_INVALID_REF; - } + ref, np->xbdev->otherend_id, + __pa(skb->data) >> PAGE_SHIFT); + + RING_GET_REQUEST(&np->rx, requeue_idx)->gref = ref; + RING_GET_REQUEST(&np->rx, requeue_idx)->id = requeue_idx; + requeue_idx++; } -- 2.30.2